package com.beacon.controller;

import com.beacon.model.Financial;
import com.beacon.service.FinancialService;
import com.beacon.tool.ResponseMessage;
import com.beacon.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 编写者：魏乾聪
 * 编写时间：2019/05/22
 * 类模块描述：资金的查询及相关增删改查
 */
@RestController(value = "/Financial")
public class FinancialController {
    @Autowired
    private FinancialService financialService;

    @RequestMapping(value = "/getFinancial")
    public String setFinancialStr(String str){
        return "你输入的名字叫："+str;
    }

    /*跨域访问*/
    @CrossOrigin

    @RequestMapping(value = "/getF")
    public Financial getF(Integer fid){
        System.out.println("输入的数据为："+fid);
        return financialService.selectByPrimaryKey(fid);
    }

    @CrossOrigin  //解决跨域问题
    @RequestMapping(value="getIsBegin")
    public List<Financial> getIsBegin(){
        System.out.println("调用资金全部类型的接口");
        List<Financial> listFinancial=financialService.getIsBegin();
        return listFinancial;
    }
    @CrossOrigin
    @RequestMapping(value = "/getAll")
    public ResponseMessage getAll(){
        System.out.println("调用角色全部信息");
        Map<String,List> map = new HashMap<>();
        map.put("list",financialService.getAll());
        return Result.success("200", map);
    }

    public void getLog(Financial financial){
        if(financial != null){
            financialService.selectByPrimaryKey(financial.getFid());
        }
    }

}